import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  {
    path: '',
    redirect: "/manage"
  },
  {
    path: '/404',
    component: () => import('../views/404.vue'),
    hidden: true
  },
  {
    path: '/manage',
    component: () => import(/* webpackChunkName: "about" */ '../views/manage.vue'),
    children: [{
      path: '',
      redirect: 'fileQuery'
    }, {
      path: 'fileManage',
      name: 'fileManage',
      component: () => import('../views/fileManage.vue'),
      meta: ['文件上传（新）'],
    }, {
      path: 'fileQuery',
      name: 'fileQuery',
      component: () => import('../views/fileQuery.vue'),
      meta: ['文件查询'],
    }, {
      path: 'fileUpload',
      name: 'fileUpload',
      // component: () => import('../views/fileUpload.vue'),
      meta: ['文件上传'],
    }, {
      path: 'totalResult',
      name: 'totalResult',
      component: () => import('../views/totalResult.vue'),
      meta: ['查看总表'],
    }]
  },
  {
    path: '*',
    redirect: '/404',
    hidden: true
  },
]

const router = new VueRouter({
  routes
})

//导航守卫，前置钩子(hook)
// router.beforeEach((to, from, next) => {
// document.title = `${to.matched[0].meta.title} | 变购链后台管理系统`;
// const role = localStorage.getItem('ms_username');
//   next()
// })

export default router
